<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=latin1">
        <link rel="stylesheet" type="text/css" href="../padrao.css" />
        <link rel="stylesheet" href="../jQuery/lista.css" type="text/css" media="all" />
        <script type="text/javascript" src="../jQuery/jquery-1.2.1.pack.js"></script>
        <script type="text/javascript" src="../jQuery/busca.js"></script>
        <script type="text/javascript" src="../sorttable.js"></script>
        <script type="text/javascript">
            function ChangeColor(tableRow, highLight)
            {
                if (highLight)
                {
                    tableRow.style = '#dcfac9';
                }
                else
                {
                    tableRow.style.backgroundColor = 'white';
                }
            }

            function vai(login)
            {
                document.location.href = "view_funcionario.php?funcionario_selecionado="+login;
            }
        </script>

        <title> Template </title>

        <?php
        include '../infobox.php';
        include '../verifica_usuario.php';
        include '../functions.php';
        include '../functions_office.php';
        include '../menu.php';
        ?>

    </head>
    <body>
        <div class="conteudo">
            <p class="titulopesquisa" align='center'> FUNCIONARIOS </p>


            <?php
            $orderby = $_GET[orderby];
            if($orderby == ""){
                $orderby = "login";
            }
            include("mysqlconfig.inc");
            $query = "select * from FUNCIONARIOS
                      ORDER BY $orderby ASC; ";
            $res = mysql_query($query);
            $num_reg = mysql_num_rows($res);
            
            echo "<table> ";
            echo "<tr class='titulo'>";
            echo "<td> Login </td>";
            echo "<td> Senha </td>";
            echo "<td> Nome </td>";
            echo "<td> Cargo </td>";
            echo "<td> Area </td>";
            echo "</tr>";

            for ($i = 0; $i < $num_reg; $i++) {
                $mostra = mysql_fetch_array($res);
                $func_login = $mostra[login];
                if ($i % 2 == 1) {
                    $tipolinha = "tipo1";
                } else {
                    $tipolinha = "tipo2";
                }
                echo "<tr class='$tipolinha'
                onmouseover='ChangeColor(this, true)'
                  onmouseout='ChangeColor(this, false);'
                  onClick='vai(\"".$func_login."\")'>
                ";
                echo "<td> $mostra[login] </td>";
                echo "<td> $mostra[senha] </td>";
                echo "<td> $mostra[nome]  </td>";
                echo "<td> $mostra[cargo] </td>";
                echo "<td> $mostra[area] </td>";
                echo "</tr>";
            }
            echo "</form>";
            echo "</table>";
            echo "$num_reg Funcionarios cadastrados <br>";
            mysql_close($con);
            //troca ordenaçao
            if($ordem == "ASC"){
              $ordem = "DESC";
              $_SESSION[ordem] = $ordem;
            }else {
                $ordem = "ASC";
              $_SESSION[ordem] = $ordem;
            }
            ?>
        </div>
    </body>
</html>